flamingo.me/flamingo-commerce/v3@v3.11.0/docs/1. Introduction/2. Graphql.md (about) 1 # Flamingo Commerce Graphql API 2 3 In Flamingo Commerce most of the modules provide GraphQL schemas and the corresponding resolvers and modifiers. 4 5 ## Usage 6 7 To enable graphql in your project follow the documentations in the "graphql" Flamingo module. (See [GraphQL Module](https://docs.flamingo.me/3.%20Flamingo%20Modules/graphql.html)) 8 9 ## Examples 10 11 See the following example queries to get a feeling on how the Flamingo Commerce GraphQL schema can be used: 12 13 ### Receiving Cart 14 ```json 15 query cartexample { 16 Commerce_Cart { 17 cart { 18 id 19 itemCount 20 deliveries { 21 deliveryInfo { 22 code 23 } 24 cartitems { 25 qty 26 productName 27 } 28 } 29 } 30 } 31 } 32 ``` 33 34 ### Adding a product to Cart 35 ```json 36 mutation add { 37 Commerce_AddToCart(marketplaceCode: "awesome-retailer_7409939", qty: 10, deliveryCode: "delivery") { 38 cart { 39 id 40 } 41 } 42 } 43 ``` 44 45 ### Receiving Products 46 47 ```json 48 query productssimple { 49 Commerce_Product(marketplaceCode: "awesome-retailer_7409939") { 50 ...productData 51 } 52 } 53 54 55 fragment productData on Commerce_Product { 56 baseData { 57 title 58 } 59 isSaleable 60 saleableData { 61 activePrice { 62 default { 63 amount 64 currency 65 } 66 discounted { 67 amount 68 currency 69 } 70 discountText 71 isDiscounted 72 } 73 } 74 } 75 ``` 76 77 This example uses GraphQL Fragments to share the common set of properties. 78 79 #### Typed Products 80 81 Product is an interface and there can be many types implementing it. 82 You can modify the query like this: 83 84 ```json 85 query productstyped { 86 Commerce_Product(marketplaceCode: "awesome-retailer_7409939") { 87 __typename 88 ... on Commerce_SimpleProduct { 89 ...productData 90 } 91 } 92 } 93 ```